//
//  MovieViewController.m
//  豆瓣
//
//  Created by hy on 16/1/9.
//  Copyright © 2016年 hongyu. All rights reserved.
//

#import "MovieViewController.h"
#import "hydateBaseHandle.h"
#import "HyModel.h"
@interface MovieViewController ()<UITableViewDataSource, UITableViewDelegate>

@end

@implementation MovieViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"我的电影";
//    创建tableView
    [self creatTableView];
}



- (void)creatTableView {
    UITableView *table = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    table.rowHeight = 50;
    table.separatorColor = [UIColor purpleColor];
    [self.view addSubview:table];
    [table release];
    table.delegate = self;
    table.dataSource = self;
    [table registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    NSArray *arr = [[hydateBaseHandle shareDataBaseHandle] selectMovieDate];
    return arr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    NSMutableArray *array = [NSMutableArray array];
    NSArray *arr = [[hydateBaseHandle shareDataBaseHandle] selectMovieDate];
    for (HyModel *model in arr) {
        NSString *str = model.title;
        [array addObject:str];
    }
    cell.textLabel.text = [NSString stringWithFormat:@"%ld : %@", indexPath.row + 1, array[indexPath.row]];
    cell.textLabel.textColor = [UIColor purpleColor];
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
